#ifndef __DH_STRUCTURES_
#define __DH_STRUCTURES_


#include 	<vector>
#include	<string>


template <class T>
class dh_hash_table
{
	private:

		struct dh_hash_item 
		{
			std::string indexName;
			T data;
		};

		std::vector <dh_hash_item> stack;

	public:

		void Clear()
		{
			stack.clear();
		}

		size_t Size() 
		{
			return stack.size();
		}

		void Add(std::string indexName, const T& data) 
		{
			for(long i=0; i<stack.size(); i++) 
			{
				if(stack[i].indexName == indexName) 
				{
					stack[i].data=data;
					return;
				}
			}   
			               
			dh_hash_item obj;
			obj.indexName=indexName;
			obj.data = data;
			stack.push_back(obj);
		}

		void Add(std::string indexName, const T* data)
		{
			for(long i=0; i<stack.size(); i++) 
			{
				if(stack[i].indexName == indexName) 
				{
					stack[i].data=*data;
					return;
				}
			}   
			               
			dh_hash_item obj;
			obj.indexName=indexName;
			obj.data = *data;
			stack.push_back(obj);
		}

		std::string GetIndexName(long index)
		{
			if(index < 0) index=0;
			return stack[index].indexName;
		}

		T  &operator [] (long index) 
		{
			if(index < 0) index=0;
			return stack[index].data;
		}


		T &operator [](std::string indexName) 
		{

			for(long i=0; i<stack.size(); i++) 
				if(stack[i].indexName == std::string(indexName)) 
					return   stack[i].data;
				
			long idx = stack.size();
			dh_hash_item obj;
			obj.indexName=indexName;
			stack.push_back(obj);  
			return stack[idx].data;             
		}        
};




#endif